<template>
	<van-search
		v-model="value"
		:placeholder="placeholder"
		:show-action="hasSlot('action')"
		@search="handleSearch"
	>
		<template #action v-if="hasSlot('action')">
			<slot name="action"></slot>
		</template>
	</van-search>
</template>
<script setup lang="ts">
import { QuickSearchProps } from './quick-search';
//  输入参数
const props = defineProps(QuickSearchProps);

const emit = defineEmits<{
	(name: 'search', searchValue: string): void;
}>();

const value = ref<string>('');

const handleSearch = (searchValue: string) => {
	emit('search', searchValue);
};
const hasSlot = (name: string) => {
	return !!useSlots()[name];
};
</script>
